Skip to content

Conversation

NonProgrammerCharacter
Copy link

@NonProgrammerCharacter NonProgrammerCharacter commented Jul 1, 2025

Change variable type of "encryption_key" from string to jsonarg as the underlying api throws an error when using an existing encryption key directly inside the variable as it becomes a string which the api doesnt like.

I have the encryption key as a dict in my ansible vault.

Debug output before the fix:
DEBUG ENCRYPTION_KEY value: "{'kdf': None, 'created': '2022-09-07T08:46:13+02:00', 'modified': '2022-09-07T08:46:13+02:00', 'data': 'xxx', 'fingerprint': 'xxx'}"

This is my debug output after the fix:
DEBUG ENCRYPTION_KEY value: {"kdf": null, "created": "2022-09-07T08:46:13+02:00", "modified": "2022-09-07T08:46:13+02:00", "data": "xxx", "fingerprint": "xxx"}

And this was the error I got when running my playbook:

ansible_loop_var: item
item:
content: backup
datastore: bpool
encryption_key: '{"kdf": null, "created": "2022-09-07T08:46:13+02:00", "modified": "2022-09-07T08:46:13+02:00", "data": "xxx", "fingerprint": "xxx"}'
name: pbs2
namespace: sbg-1
password: xxx
server: pbs2.xxx.de
type: pbs
username: pve-dev@pbs
msg: encryption_key needs to be valid JSON or set to 'autogen'.

With this fix my storage configuration is using the encryption key from my ansible vault and can access our backups.

Change variable type of "encryption_key" from string to jsonarg as the underlying api throws an error when using an existing encryption key directly inside the variable as it becomes a string which the api doesnt like.
@simoncaron
Copy link
Contributor

@lae any chance we can merge this PR? Currently the proxmox_storage.py library isn't parsing a JSON encryption_key properly. I tried multiple quoting/formating and none work properly.

This change fixes JSON encryption_keys and keep the autogen option working too (tested both on my side without issue).

@lae
Copy link
Owner

lae commented Aug 29, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants